package com.gidgabs.modules.entity;

import com.gidgabs.dto.TbUserJournalDto;

import java.io.Serializable;
import java.util.Date;



/**
 * 用户关系表-日志表
 * 
 * @author lanyonglin
 * @email www.baidu.com
 * @date 2018-07-03 10:06:06
 */
public class TbUserJournalEntity implements Serializable {
	private static final long serialVersionUID = 1L;
	
	//
	private Integer id;
	//作者编号
	private Integer userId;
	//创建时间
	private Date createTime;
	//产品图片
	private String pictureUrl;
	/**点赞数量*/
	private Integer starNum;
	/**查看数量*/
	private Integer watchNum;
	/**转载来源作者id*/
	private Integer sourceUserId;
	/**转载来源日志id*/
	private Integer sourceId;

	//视频id（阿里云视频表 vid）
	private Integer gidgabsVideoId;
	//判断是否已删除 0:未删除，1:已删除
	private Integer deleteType;
	//
	private String description;
	/**发表状态: 0,未发表成功,1发表成功*/
	private Integer status;
	private String label;
	private Integer rewardMoney;
	private Integer rewardNum;

	public TbUserJournalEntity() {
	}

	public TbUserJournalEntity(Integer userId, Integer gidgabsVideoId, String pictureUrl, String description, String label, Integer rewardMoney, Integer rewardNum) {
		this.userId=userId;
		this.gidgabsVideoId=gidgabsVideoId;
		this.pictureUrl=pictureUrl;
		this.deleteType=0;
		this.description=description;
		starNum=0;
		watchNum=0;
		this.createTime=new Date();
		this.label=label;
		if (rewardMoney==0||rewardMoney==null){
			this.rewardMoney=0;
			this.rewardNum=0;
			this.status=1;
		}else {
			status=0;
			this.rewardMoney=rewardMoney;
			this.rewardNum=rewardNum;
		}
	}

	/**
	 * 设置：
	 */
	public void setId(Integer id) {
		this.id = id;
	}
	/**
	 * 获取：
	 */
	public Integer getId() {
		return id;
	}

	public Integer getUserId() {
		return userId;
	}

	public void setUserId(Integer userId) {
		this.userId = userId;
	}

	public Integer getSourceUserId() {
		return sourceUserId;
	}

	public void setSourceUserId(Integer sourceUserId) {
		this.sourceUserId = sourceUserId;
	}

	public Integer getSourceId() {
		return sourceId;
	}

	public void setSourceId(Integer sourceId) {
		this.sourceId = sourceId;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getLabel() {
		return label;
	}

	public void setLabel(String label) {
		this.label = label;
	}

	public Integer getRewardMoney() {
		return rewardMoney;
	}

	public void setRewardMoney(Integer rewardMoney) {
		this.rewardMoney = rewardMoney;
	}

	public Integer getRewardNum() {
		return rewardNum;
	}

	public void setRewardNum(Integer rewardNum) {
		this.rewardNum = rewardNum;
	}

	/**
	 * 设置：创建时间
	 */
	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}
	/**
	 * 获取：创建时间
	 */
	public Date getCreateTime() {
		return createTime;
	}

	public String getPictureUrl() {
		return pictureUrl;
	}

	public void setPictureUrl(String pictureUrl) {
		this.pictureUrl = pictureUrl;
	}

	public Integer getGidgabsVideoId() {
		return gidgabsVideoId;
	}

	public void setGidgabsVideoId(Integer gidgabsVideoId) {
		this.gidgabsVideoId = gidgabsVideoId;
	}

	public Integer getStarNum() {
		return starNum;
	}

	public void setStarNum(Integer starNum) {
		this.starNum = starNum;
	}

	public Integer getWatchNum() {
		return watchNum;
	}

	public void setWatchNum(Integer watchNum) {
		this.watchNum = watchNum;
	}

	/**
	 * 设置：判断是否已删除 0:未删除，1:已删除
	 */
	public void setDeleteType(Integer deleteType) {
		this.deleteType = deleteType;
	}
	/**
	 * 获取：判断是否已删除 0:未删除，1:已删除
	 */
	public Integer getDeleteType() {
		return deleteType;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public TbUserJournalDto toDto(){
		TbUserJournalDto tbuserjournaldto=new TbUserJournalDto();
		tbuserjournaldto.setPictureUrl(this.getPictureUrl());
		tbuserjournaldto.setDeleteType(this.getDeleteType());
		tbuserjournaldto.setCreateTime(this.getCreateTime());
		tbuserjournaldto.setUserId(this.getUserId());
		tbuserjournaldto.setGidgabsVideoId(this.getGidgabsVideoId());
		tbuserjournaldto.setId(this.getId());
		tbuserjournaldto.setDescription(this.getDescription());
		tbuserjournaldto.setRewardMoney(this.getRewardMoney());
		tbuserjournaldto.setRewardNum(this.getRewardNum());
		tbuserjournaldto.setStarNum(this.getStarNum());
		tbuserjournaldto.setWatchNum(this.getWatchNum());
		return tbuserjournaldto;
	}

	/**
	 * 包含视频相关字段
	 * @param tbAliyunVideoEntity
	 * @return
	 */
	public TbUserJournalDto toDto(TbAliyunVideoEntity tbAliyunVideoEntity) {
		TbUserJournalDto tbuserjournaldto=toDto();
		tbuserjournaldto.setPictureUrl(this.getPictureUrl());
		tbuserjournaldto.setDeleteType(this.getDeleteType());
		tbuserjournaldto.setCreateTime(this.getCreateTime());
		tbuserjournaldto.setUserId(this.getUserId());
		tbuserjournaldto.setGidgabsVideoId(this.getGidgabsVideoId());
		tbuserjournaldto.setId(this.getId());
		tbuserjournaldto.setDescription(this.getDescription());


		tbuserjournaldto.setVideoId(tbAliyunVideoEntity.getVideoId());
		tbuserjournaldto.setTags(tbAliyunVideoEntity.getTags());
		tbuserjournaldto.setCoverurl(tbAliyunVideoEntity.getCoverurl());
		tbuserjournaldto.setDescription(tbAliyunVideoEntity.getDescription());
		tbuserjournaldto.setTitle(tbAliyunVideoEntity.getTitle());
		tbuserjournaldto.setFileName(tbAliyunVideoEntity.getFileName());

		return tbuserjournaldto;
	}

	/**
	 * 转载日志,生成一条新的数据,用来插入数据库
	 * @param currentUserId
	 * @return
	 */
    public TbUserJournalEntity reprint(Integer currentUserId) {
		int sourceId=this.getSourceId()==null?this.getId():this.getSourceId();
		int sourceUserId=this.getSourceUserId()==null?this.getUserId():this.getSourceUserId();
		this.sourceUserId=sourceUserId;
		this.sourceId=sourceId;
		this.userId=currentUserId;
		this.id=null;
		this.watchNum=0;
		this.starNum=0;
		this.createTime=new Date();
		return this;
    }
}
